<template>
  <div>
    <input type="text" :value="value" style="display: none" />
    <el-select
      v-model="selected"
      :clearable="clearable"
      :size="size"
      :placeholder="placeholder"
      @change="handleItemChange"
    >
      <el-option
        v-for="(item, key) in enumFarmType"
        :key="key"
        :label="item"
        :value="key"
      ></el-option>
    </el-select>
  </div>
</template>

<script>
import { enumFarmType } from '@/credit/plugins/enum'

export default {
  components: {},
  props: {
    value: {
      type: String,
      default: '',
    },
    size: {
      type: String,
      default: '',
    },
    placeholder: {
      type: String,
      default: '选择类型',
    },
    clearable: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      enumFarmType,
      selected: null,
    }
  },
  computed: {},
  watch: {
    value(val) {
      this.selected = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleItemChange(val) {
      this.$emit('input', val)
      this.$emit('change', val)
    },
  },
}
</script>

<style scoped></style>
